<template>
  <div class="flex flex-col day-done-exception">
    <line-logo :name="$i18n.t('mesProductionDailyClear.abnormalSituation')" />
    <div class="mt-24 flex align-center top-item justify-around">
      <div
        class="flex align-end content-center"
        v-for="(item, index) in topArr"
        :key="index"
      >
        <div class="flex flex-col ml-12 align-center">
          <span class="color-5A6F82">{{ item.label }}</span>
          <strong class="font-20 color-333 mt-8">{{ item.value || 0 }}</strong>
        </div>
      </div>
    </div>
    <div class="flex align-center mt-18 content-between">
      <strong class="font-13">{{
        $i18n.t("mesProductionDailyClear.toBeTreatedAbnormalDetails")
      }}</strong>
      <el-button type="primary" @click="handleExport" icon="el-icon-download">{{
        $i18n.t("common.export")
      }}</el-button>
    </div>
    <el-table
      class="mt-12"
      :max-height="350"
      :data="dataItem.awaitDefectInfoList"
    >
      <el-table-column
        :label="$i18n.t('common.order')"
        type="index"
        align="center"
        width="50"
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.specifiedProduct')"
        prop="prodName"
        width="110"
        align="center"
        show-tooltip-when-overflow
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.prodCode')"
        prop="prodCode"
        width="100"
        align="center"
        show-tooltip-when-overflow
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.amount')"
        prop="number"
        align="center"
        width="60"
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.liability')"
        prop="productProcessName"
        width="110"
        align="center"
        show-tooltip-when-overflow
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.submitter')"
        prop="createBy"
        width="120"
        show-tooltip-when-overflow
        align="center"
        min-width="120"
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.submissionTime')"
        prop="createTime"
        width="160"
        align="center"
        min-width="120"
        show-tooltip-when-overflow
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.badState')"
        prop="reviewStatus"
        width="100"
        align="center"
        show-tooltip-when-overflow
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.processResult')"
        prop="reviewResult"
        width="100"
        align="center"
        show-tooltip-when-overflow
      />
      <el-table-column
        :label="$i18n.t('mesProductionDailyClear.repairs')"
        prop="repairStatus"
        show-tooltip-when-overflow
        width="100"
        align="center"
      />
    </el-table>
  </div>
</template>

<script>
import LineLogo from "./line-logo.vue";
import { exportUrlDefect } from "@/api/report/mesProductionDailyClear";
import { exportExcel } from "@/utils/judge";

export default {
  components: { LineLogo },
  props: {
    dataItem: {
      type: Object,
      default: () => {},
    },
    dataQuery: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    dataItem: {
      handler(val) {
        this.topArr[0].value = val.defectNum || 0;
        this.topArr[1].value = val.shutNum || 0;
        this.topArr[2].value = val.awaitNum || 0;
      },
      immediate: true,
      deep: true,
    },
  },
  data() {
    return {
      topArr: [
        {
          label: $i18n.t("mesProductionDailyClear.totalExceptionCount"),
          value: 3,
          icon: "icon_yczs",
        },
        {
          label: $i18n.t("mesProductionDailyClear.closed"),
          value: 3,
          icon: "icon_ygb",
        },
        {
          label: $i18n.t("mesProductionDailyClear.pending"),
          value: 3,
          icon: "icon_dcl",
        },
      ],
      dataList: [],
    };
  },
  methods: {
    handleExport() {
      this.$confirm(
        $i18n.t("mesProductionDailyClear.exportConfirm"),
        $i18n.t("common.warning"),
        {
          confirmButtonText: $i18n.t("common.ok"),
          cancelButtonText: $i18n.t("common.cancel"),
          type: "warning",
        }
      ).then(() => {
        exportExcel(exportUrlDefect, this.dataQuery);
      });
    },
  },
};
</script>
<style lang="scss">
.day-done-exception {
  .top-item {
    border-top: 4px solid #f26a60;
    height: 125px;
    border-right: 1px solid #e5e5e5;
    border-left: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
  }
}
</style>
